﻿using System;
using System.ComponentModel;

namespace TfsMerge.BO
{
    public abstract class BaseBindObject : INotifyPropertyChanged
    {
        protected bool SetValue<T>(ref T property, T value, string propertyName)
        {
            var result = false;
            if (!Equals(property, value))
            {
                property = value;
                RaisePropertyChanged(propertyName);
                result = true;
            }

            return result;
        }

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        protected void RaisePropertyChanged(string propertyName)
        {
            var handler = PropertyChanged;
            if (handler != null && !String.IsNullOrEmpty(propertyName))
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        #endregion

    }

}
